import Vue from 'vue'
import App from './App.vue'
import router from './router'
import iView  from 'iview'
import 'iview/dist/styles/iview.css'

Vue.use(iView);

Vue.config.productionTip = false

new Vue({
    router,
    render: h => h(App),
    // 登录校验
    mounted: function () {
        let _this = this;
        if (this.$route.name !== 'login') {
            this.$http.post('/api/v1/admin', {'check': 1})
            .then(function (response) {
                if (response.data.code === 0) {

                } else {
                    // 清空jwt
                    localStorage.setItem('jwt', '');
                    _this.$router.replace({path: '/login'});
                }
            })
            .catch(function (error) {
                console.log(error)
            });
        }
    }
}).$mount('#app')
